<template>
  <div>
    <button @click="runCommandGet">测试Get传参</button>
    <button @click="runCommandPost">测试Post传参</button>
    <button @click="runCommandPython">Python九九乘法表</button>
    <pre>{{ output }}</pre>
  </div>
</template>

<script>
import { testNodeGet, TestNodePost, testPyScript } from "@/api/modules/node.js";
export default {
  data() {
    return {
      output: "",
    };
  },
  methods: {
    async runCommandGet() {
      try {
        const params = { name: "张三" };
        const response = await testNodeGet(params);
        this.output = response.result;
      } catch (error) {
        this.output = "Error: " + error;
      }
    },
    async runCommandPost() {
      try {
        const params = { name: "张三", age: 28, type: "user" };
        const response = await TestNodePost(params);
        this.output = response.result;
      } catch (error) {
        this.output = "Error: " + error;
      }
    },
    async runCommandPython() {
      try {
        const params = {};
        const response = await testPyScript(params);
        this.output = response.result;
      } catch (error) {
        this.output = "Error: " + error;
      }
    },
  },
};
</script>

<style scoped lang="scss">
button {
  margin-right: 12px;
}
</style>
